All Questions
13 questions
4votes
4answers
1kviews
Check if a binary tree is symmetric in Python
I have solved the following Leetcode problem. Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric....
1vote
1answer
203views
Maximum Width binary tree
Here is my code for the LeetCode problem For a given binary tree, find the maximum width of the binary tree. The width of one level is defined as the length between the end-nodes even if there are <...
8votes
2answers
2kviews
Word-Ladder solver in Python 3
Follow-up to Python program to find a word ladder transforming "four" to "five" I'm trying to write a program to solve a word ladder puzzle to brush up on my Python. For those who ...
1vote
1answer
487views
Python program for Word Search II
This is a Leetcode problem - Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of a sequentially adjacent ...
-4votes
1answer
94views
Finding the sublist with best utility function among all list's permutations [closed]
I try to find the the better solution in terms of time complexity. Among the list of elements I need to find the sublist with maximum value of given utility function. Each element has it's own type. ...
2votes
1answer
2kviews
Given a binary tree, find the maximum path sum
This is a leetcode.com problem. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must ...
1vote
1answer
2kviews
Generating and finding parent nodes in a post-order tree
Given a height h and list q of integers, list the parent node of each element in q, if nodes are read in post-order sequence ...
6votes
2answers
957views
HackerRank Binary search tree validation
From here: ...
3votes
1answer
2kviews
"The Story of a Tree" solved using depth-first search
Found this problem in hackerrank. One day Bob drew a tree, with \$n\$ nodes and \$n-1\$ edges on a piece of paper. He soon discovered that parent of a node depends on the root of the tree. The ...
4votes
1answer
174views
Counting increasing subsequences with a "hacker's" Binary Index Tree
This is an \$O(n \sqrt n)\$ solution to the the following problem: Given a sequence, compute the number of non-empty increasing subsequences The algorithm is to compute ...
3votes
1answer
1kviews
Request for memory optimizations for solution to Google FooBar challenge, "ion_flux_relabeling,"
I just finished one of the Google FooBar Challenges.My Python is super rusty. I did the challenge in Haskell first and then attempted to covert the code. I am guessing that led to some bad Python ...
15votes
5answers
9kviews
Google Foobar Challenge: Lucky Triples
Note: Since my time has passed for this challenge, I do not remember exactly the stipulations but will attempt to recapitulate them to the best of my knowledge. Essentially, the challenge was this: ...
6votes
2answers
660views
"File Fix-it" challenge
I'm learning Python and have found this problem from Google Code Jam: How many mkdir commands does it take to construct a given directory tree: Input The first ...